package org.example.study.liaoxuefeng.ThreadSynchronization;

import org.testng.annotations.Test;

/**
 * @author: 默苍璃
 * @date: 2023-05-23 15:20
 * <p>
 * 线程同步
 */
public class ThreadSynchronization {

    /**
     * 如果多个线程同时读写共享变量，会出现数据不一致的问题。
     */
    @Test
    public void test() throws InterruptedException {
        var add = new AddThread();
        var dec = new DecThread();
        add.start();
        dec.start();
        add.join();
        dec.join();
        System.out.println(Counter.count);
    }

}




